//////////////////////////////////////////////////////////////////////////////////
//
//	DoD Headshot Sounds
//		- Version 1.2
//		- 06.07.2006
//		- diamond-optic
//
//////////////////////////////////////////////////////////////////////////////////
//
// Information:
//
//    - Will play 1 of 3 (random) dod source headshot
//      sounds when a player dies from a headshot
//
// Extra:
//
//      Put the "headshot1.wav" in /dod/sound/misc/
//      Put the "headshot2.wav" in /dod/sound/misc/
//      Put the "headshot3.wav" in /dod/sound/misc/
//
// Changelog:
//
//    - 05.07.2006 Version 1.0
//  	   Initial Release
//
//    - 05.12.2006 Version 1.1
//  	   Changed emit_sound vol from 1.0 to 0.8 as it blends in better
//
//    - 06.07.2006 Version 1.2
//  	   Changed emit_sound vol from 0.8 to 0.75
//
//////////////////////////////////////////////////////////////////////////////////

#include <amxmodx>
#include <dodx>

new hs_sounds[3][] =
{
	"misc/headshot1.wav",
	"misc/headshot2.wav",
	"misc/headshot3.wav"
}

enum
{
	hs1,
	hs2,
	hs3
}

public plugin_init()
{
	register_plugin("DoD Headshot Sounds", "1.2", "AMXX DoD Team")
	
	register_cvar("dod_headshot_sounds_stats", "1.2", FCVAR_SERVER|FCVAR_SPONLY)
	
	register_statsfwd(XMF_DEATH)
}

public plugin_precache()
{
	precache_sound(hs_sounds[hs1])
	precache_sound(hs_sounds[hs2])
	precache_sound(hs_sounds[hs3])
}

public client_death(killer,victim,wpnindex,hitplace,TK){
	
	if(hitplace == HIT_HEAD)
		headshot_play(victim)
}

public headshot_play(victim)
{
	if (!is_user_connected(victim))
		return PLUGIN_CONTINUE

	switch(random_num(0, 2))
		{
		case 0:	emit_sound(victim, CHAN_AUTO, hs_sounds[hs1], 0.8, ATTN_NORM, 0, PITCH_NORM)
		case 1:	emit_sound(victim, CHAN_AUTO, hs_sounds[hs2], 0.8, ATTN_NORM, 0, PITCH_NORM)
		case 2:	emit_sound(victim, CHAN_AUTO, hs_sounds[hs3], 0.8, ATTN_NORM, 0, PITCH_NORM)
		}
		
	return PLUGIN_CONTINUE
}
